import { E_PrayEffectType } from "../defs/lord/E_PrayEffectType";
import { CDLordPraySkill } from "../excel/CDLordPraySkill";
import { CDMath } from "../excel/CDMath";
import { Player } from "../struct/Player";
import { SDPlayer } from "./SDPlayer";



/**
 * 数据-祝福
 */
export abstract class SDPray {

    /**
     * 获取指定类型的加成
     * @param player 
     * @param type 
     * @returns 
     */
    public static getEffectByType(player: Player, type: E_PrayEffectType): number {
        let v = 0;
        if (player) {
            const ks = player.getPrayLevelKeys();
            const vs = player.getPrayLevelValues();
            for (let i = 0, len = ks.length; i < len; i++) {
                const config = CDLordPraySkill.getData(ks[i]);
                if (!config || type !== config.effectType) {
                    continue;
                }
                const level = vs[i];
                const added = config.param + config.paramGrow * (level - 1);
                v += added;
            }
        }
        return v;
    }


    /**
     * 添加属性
     * @param player 
     */
    public static addMath(player: Player, outList: number[]): void {

        const ks = player.getPrayLevelKeys();
        const vs = player.getPrayLevelValues();

        for (let i = 0, len = ks.length; i < len; i++) {
            const config = CDLordPraySkill.getData(ks[i]);
            if (!config || E_PrayEffectType.AddMath !== config.effectType) {
                continue;
            }
            const mathId = config.param + config.paramGrow * (vs[i] - 1);
            const mathConfig = CDMath.getData(mathId);
            if (!mathConfig) {
                continue;
            }
            SDPlayer.addMathConfig(mathConfig, outList);
        }
    }


}
